<template>
	<div style="background-color:white;">
		<mu-appbar title="修改密码" class="example-appbar">
    	<!--<mu-icon-button slot="left" href="#/Index"  icon="arrow_back"></mu-icon-button>-->
    	<mu-icon-button slot="left" @click="goBack" icon="arrow_back"></mu-icon-button>
	 	</mu-appbar>
    	<!--<mu-appbar/>-->
	 	    <div class="login-form">
		      		<mu-text-field label="原密码" hintText="原密码" v-model="password" type="password" labelFloat /><br/> 
		          <mu-text-field label="新密码" hintText="请输入密码" v-model="newPassword" type="password" labelFloat/><br/>
		    	  	<mu-text-field label="确认密码" hintText="请再次输入密码" v-model="ckPassword" type="password" labelFloat/><br/>
		    	    <mu-raised-button label="确认" @click="check" class="demo-raised-button" fullWidth primary/>
		    </div>
	</div>
</template>
<script>

export default {
 	name: '',
    data () {
      return {
       password:'',
       ckPassword:'',
       newPassword:'',
       valdate:false,
       valdateMsg:'',
       name:''
      }
    },
    methods: {
      	check(){
      		let that = this
          if(that.newPassword.length>=6){
            if(that.ckPassword==that.newPassword){
          		that.axios.post('/gleenSoft-base/changePwd',{password:that.password,newPassword:that.newPassword}).then(function (response) {
                that.$parent.showToast(response.data.msg)
                if(response.data.status=='success'){
                  that.$parent.toggle()
                  that.$parent.logout()
                }
      	      })
            }else{
              that.$parent.showToast("确认密码与新密码不一致")
            }
          }else{
              that.$parent.showToast("密码长度请大于6位字符")
          }
      	},
      	goBack(){
	     	this.$router.go(-1)
	     }
    },watch:{
      newPassword:function(val,oldVal){
        if(val.length<6){
          this.valdateMsg='密码长度应大于6位字符'
        }
      },
      ckPassword:function(val,oldVal) {
         if(val != this.newPassword){
          this.valdateMsg='确认密码与新密码不一致'
        }
      }
    }
}
</script>
<style >
 
</style>